/* GUI CONVERTED from relsiq.p (converter v1.75) Sat Aug 12 23:06:06 2000 */
/* relsiq.p - REPETITIVE LINE SCHEDULE INQUIRY                              */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                      */
/* All rights reserved worldwide.  This is an unpublished work.             */
/*V8:ConvertMode=Report                                              */
/* REVISION 9.1      CREATED: 06/07/99  BY: *N005* Luke Pokic */
/* REVISION: 9.1     LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1     LAST MODIFIED: 08/12/00 BY: *N0KP* myb                 */


          /* DISPLAY TITLE */

/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

          {mfdtitle.i "b+ "}


/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE relsiq_p_1 "Line"
/* MaxLen: 6 Comment: Production line*/

&SCOPED-DEFINE relsiq_p_2 "Release Date"
/* MaxLen: 12 Comment: */

&SCOPED-DEFINE relsiq_p_3 "Site"
/* MaxLen: 5 Comment: */

&SCOPED-DEFINE relsiq_p_4 "!Rel Date"
/* MaxLen: 8 Comment: Release date*/

&SCOPED-DEFINE relsiq_p_5 "!Run Seq 1"
/* MaxLen: 9 Comment: Primary sort sequence*/

&SCOPED-DEFINE relsiq_p_6 "!Run Seq 2"
/* MaxLen: 9 Comment: Secondary sort sequence*/

&SCOPED-DEFINE relsiq_p_7 "Scheduled!Completed"
/* MaxLen: 12 Comment: Quantity scheduled*/

&SCOPED-DEFINE relsiq_p_9 "Item Number!Description"
/* MaxLen: 24 Comment: */

/* ********** End Translatable Strings Definitions ********* */

         define variable prline       like rps_line.
         define variable release_date like rps_rel_date.
         define variable site         like rps_site.

         site = global_site.

         for first ln_mstr fields(ln_line) where ln_site = global_site
         no-lock: end.
         prline = if available(ln_mstr) then ln_line else "".

           release_date = today.

         
/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
            
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
site                  label {&relsiq_p_3} colon 6
            prline                label {&relsiq_p_1} colon 23
            release_date          label {&relsiq_p_2} colon 48
         with frame a side-labels width 80 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



         /* SET EXTERNAL LABELS */
         setFrameLabels(frame a:handle).

         {wbrp01.i}

         repeat:
            if c-application-mode <> 'WEB' then do:
               update
               site
               prline
               release_date
               with frame a editing:

               if frame-field = "prline" then do:
                  /*FIND NEXT/PREVIOUS RECORD */
                  {mfnp05.i rps_mstr rps_site_line
                  "rps_site = input site and rps_line <> input prline"
                   rps_line "input prline"}
                  if recno <> ? then
                  display rps_line @ prline rps_site @ site with frame a.
               end.
               else if frame-field = "site" then do:
                  /* FIND NEXT/PREVIOUS RECORD */
                  {mfnp05.i rps_mstr rps_site_line
                     true rps_site "input site"}
                  if recno <> ? then do:
                     display
                        rps_site @ site
                        rps_line @ prline
                     with frame a.
                     recno = ?.
                  end.
               end.
               else do:
                   status input.
                   readkey.
                   apply lastkey.
               end.

               end. /* UPDATE ... EDITING */

               if release_date = ? then do:
                  /* DATE REQUIRED */
                  {mfmsg.i 711 3}
                  next-prompt release_date with frame a .
                  undo, retry.
               end.

            end.

            {wbrp06.i &command = update
               &fields = " site prline release_date"
               &frm = "a"}
            if c-application-mode <> 'WEB'
            or (c-application-mode = 'WEB'
            and c-web-request begins 'DATA') then do:

               for first si_mstr fields() no-lock where si_site = site: end.
               if not available si_mstr then do with frame a:
                  {mfmsg.i 708 3}
                  /* ERROR: SITE DOES NOT EXIST */
                  if c-application-mode = 'WEB' then return.
                  else next-prompt site.
                  undo, retry.
               end.

               for first ln_mstr fields() no-lock where ln_line = prline: end.

               if not available ln_mstr
               and prline > "" then do:
                  {mfmsg.i 8524 3}
                  /* ERROR: PRODUCTION LINE DOES NOT EXIST */
                  if c-application-mode = 'WEB' then return.
                  else next-prompt prline with frame a.
                  undo, retry.
               end.

               for first ln_mstr fields() no-lock where ln_line = prline
               and ln_site = site: end.
               if not available ln_mstr then do:
                  for first ln_mstr fields() no-lock where ln_site = site: end.
                  if available ln_mstr then do:
                     {mfmsg.i 8526 3}
                     /* ERROR: SITE PRODUCTION LINE DOES NOT EXIST */
                     if c-application-mode = 'WEB' then return.
                     else next-prompt prline with frame a.
                     undo, retry.
                  end.
               end.

               status input.

               hide frame b.

            end.

            /* SELECT PRINTER */
            {mfselprt.i "terminal" 80}
/*GUI*/ RECT-FRAME:HEIGHT-PIXELS in frame a = FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.


            /* MAIN LOOP */
            /* SORTING IS DONE ON FIELDS FROM 2 TABLES */
            /* ALTERNATIVE SOLUTION FOR SORTING IS A TEMP TABLE */
            /* WITH APPROPRIATE INDEX FOR SORT FIELDS */
            /* WINDOW OF 7 DAYS FOR RELEASE DATE IS SPECIFIED */
            /* IN THE DETAIL DESIGN */
            for each rps_mstr fields(rps_site rps_line rps_part rps_rel_date
            rps_qty_req rps_qty_comp) no-lock
            where rps_site = site
            and rps_line = prline
            and ((rps_rel_date >= release_date
                  and rps_rel_date <= release_date + 6)
                  or release_date = ?),

            last lnd_det
            fields(lnd_part lnd_line lnd_site lnd_start
            lnd_run_seq1 lnd_run_seq2) no-lock
            where lnd_line = rps_line
            and lnd_site = rps_site
            and lnd_part = rps_part
            and lnd_start <= rps_rel_date,

            first pt_mstr fields(pt_part pt_desc1) no-lock
            where pt_part = rps_part

            by rps_rel_date
            by lnd_run_seq1
            by lnd_run_seq2
            by rps_part

            with frame b width 80:

               /* SET EXTERNAL LABELS */
               setFrameLabels(frame b:handle).
               
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


               FORM /*GUI*/ 
                  rps_rel_date column-label {&relsiq_p_4} at 1
                  lnd_run_seq1 column-label {&relsiq_p_5} at 11
                  lnd_run_seq2 column-label {&relsiq_p_6} at 22
                  rps_part column-label {&relsiq_p_9} at 33
                  rps_qty_req column-label {&relsiq_p_7} at 60.

               display
               rps_rel_date
               lnd_run_seq1
               lnd_run_seq2
               rps_part
               rps_qty_req WITH STREAM-IO /*GUI*/ .
               down 1.

               display
               pt_desc1 @ rps_part
               rps_qty_comp @ rps_qty_req WITH STREAM-IO /*GUI*/ .

            end.

            {mfreset.i}
/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/

            {mfmsg.i 8 1}
            /* LIST COMPLETE */

            global_site = site.

         end.

         {wbrp04.i &frame-spec = a}
